MockMotor Log

MockMotor file log can be used to troubleshoot more complex issues, such as defects in MockMotor itself (as much as I try to avoid them).

Log Location

The log file is named mockmotor.log.0 (rotated to *.1 ... *.9) and, by default, is located in the logs/ directory under the data directory.

To change the log location, update config file mockmotor.config.xml file to point to the desired location then restart MockMotor.

The location can be relative to the data directory or absolute. Here, the location is set to be relative to the data directory, i.e. ./logs. The data directory itself (.) is set to the directory where MockMotor starts from:

<config xmlns="http://mockmotor.com/config">
    <dataDirectory>.</dataDirectory>
    ...
    <logsDirectory>logs</logsDirectory>
</config>

Log Structure

Test Requests

MockMotor logs the test requests performed by the client applications.

Each log entry contains:

  • HTTP method that was used
  • HTTP status MockMotor generated
  • Overall time the request took
  • Mock environment the request was routed to
  • Mock service the request was routed to
  • Reaction that matched the request
  • Request URI
2017-08-13 10:50:45.888 INFO HTTP DELETE 200     2ms [MockMotor SelfTest][REST][DELETE products] /SelfTest/REST/products/74755
2017-08-13 10:50:45.900 INFO HTTP    PUT 200     2ms [MockMotor SelfTest][REST][PUT products] /SelfTest/REST/products/74755
2017-08-13 10:50:45.913 INFO HTTP   POST 200     3ms [MockMotor SelfTest][REST][POST products] /SelfTest/REST/products
2017-08-13 10:50:45.925 INFO HTTP   POST 200     3ms [MockMotor SelfTest][REST][POST customers] /SelfTest/REST/customers
2017-08-13 10:50:46.070 INFO HTTP    PUT 201   136ms [MockMotor SelfTest][REST JSON][Has $rest everywhere even without relativeURI match] /SelfTest/RESTJSON/products/74755
2017-08-13 10:50:46.084 INFO HTTP    GET 200     5ms [MockMotor SelfTest][REST JSON][GET customer 12345] /SelfTest/RESTJSON/customers/12345
2017-08-13 10:50:46.099 INFO HTTP    GET 200     5ms [MockMotor SelfTest][REST JSON][GET Customer 12345 Orders Lineitem #1] /SelfTest/RESTJSON/customers/12345/orders/854/lineitems/1
2017-08-13 10:50:46.117 WARN Badly formatted multipart request
2017-08-13 10:50:46.125 INFO HTTP  PATCH 200     3ms [MockMotor SelfTest][HTTP][HTTP Properties XML] /SelfTest/HTTP/Properties
2017-08-13 10:50:46.142 INFO HTTP   POST 200     3ms [MockMotor SelfTest][HTTP][HTTP Properties XML (POST)] /SelfTest/HTTP/Properties
2017-08-13 10:50:46.165 INFO HTTP  PATCH 200     3ms [MockMotor SelfTest][HTTP][HTTP Properties XML] /SelfTest/HTTP/Properties?a=1&b=2
2017-08-13 10:50:46.196 SEVE Error executing matcher for reaction 86dd1ce5-715c-4ae1-9bdd-337f86d73c23 Match by Broken Javascript - 
ignored, moved on: sun.org.mozilla.javascript.internal.EvaluatorException: Unexpected end of file (#1) in  at line number 1
2017-08-13 10:50:46.199 INFO HTTP   POST 200    12ms [MockMotor SelfTest][JSON][http] /SelfTest/JSON/http?a=100&b=200&b=300
2017-08-13 10:50:46.229 INFO HTTP   POST 200    15ms [MockMotor SelfTest][MockMeta][Meta in Matcher (XQ)] /SelfTest/Meta/MockMetaInMatcher-XQ

Human Actions

MockMotor logs updating requests that are generated by the logged in users. The log entry contains the full name of the user that has performed the change:

2017-08-15 23:27:55.929 INFO Saved response PTE::OMF ProductConfiguration JSON::B1 ChangeService R3
2017-08-15 23:27:55.933 INFO HTTP   POST 200   114ms [PTE][OMF ProductConfiguration JSON][B1 ChangeService R3] (Vladimir Dyuzhev) /console/ajax/response

Read-only (HTTP GET) requests performed by users are not logged so that they do not clog the file.

API Requests

Updates performed via API are logged as well. Note that read-only requests via API are not logged.

2017-08-15 23:28:13.936 INFO HTTP   POST 200     6ms [MockMotor SelfTest Accounts][][] /console/api/account
2017-08-15 23:28:13.955 INFO HTTP DELETE 200     2ms [MockMotor SelfTest Accounts][][] /console/api/account?accid=052c95d6-63eb-471a-afc2-c0cbe94125f8

Errors

In case of unexpected errors MockMotor logs the error message, stacktrace and the request that caused the error:

2017-08-13 12:57:21.175 SEVE While executing reaction 'Selecting Account with JSONPath and not found' eb953e8c-9db2-4c96-9548-95ab1c83336b
com.rfctr.mockmotor.engine.MockMotorException: No accounts found with 
  variable var_a matching values 'null' computed as '$.var_abcd'
in reaction 'Selecting Account with JSONPath and not found'
	com.rfctr.mockmotor.responses.ResponseExecutor.matchAndExecuteResponse(ResponseExecutor.java:111)
	com.rfctr.mockmotor.engine.MockMotorRequestsHandler.handle(MockMotorRequestsHandler.java:188)
	...
2017-08-13 12:57:21.175 SEVE Failed request {	"var_a":"01",	"other": {		"ban":"62363463"	}}